package com.lyb.springbootredisclient.app.impl;

import com.lyb.springbootredisclient.app.BpxhAbstractApprovalService;
import org.springframework.beans.factory.ListableBeanFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.ApplicationContext;
import org.springframework.stereotype.Service;

import java.util.Map;

/**
 * @author: lyb  2024/3/26 16:36
 */
@Service
public class BpxhApprovalServiceFactory {
    @Autowired
  ListableBeanFactory listableBeanFactory;
  public  BpxhAbstractApprovalService  buildApprovalService(String cat){
        Map<String, BpxhAbstractApprovalService> beansOfType = listableBeanFactory.getBeansOfType(BpxhAbstractApprovalService.class);
        for (Map.Entry<String, BpxhAbstractApprovalService> abstractApprovalService: beansOfType.entrySet()) {
            if(cat.equals(abstractApprovalService.getValue().approvalType())){
                return abstractApprovalService.getValue();
            }
        }
        return null;
    }
}
